<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Cache-Control"  content="no-transform">
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>购物车</title>
    <link href="/statics/view/css/yy_common.css" rel="stylesheet">
    <link href="/statics/view/css/yy_detail.css" rel="stylesheet">
    <link href="/statics/view/css/yy_cart.css" rel="stylesheet">
</head>
<body>
<body>
<script src="//cdn.bootcss.com/jquery/2.1.0/jquery.min.js"></script>
<script src="/statics/view/js/db.js"></script>
<div class="m-simpleHeader" id="pro-view-0">
    <a href="javascript:void(0);" data-pro="back" data-back="true"class="m-simpleHeader-back">
        <i class="ico ico-back"></i>
    </a>
    <h1>清单</h1>
</div>
<form action="/db/pay/order" method="GET">
<div class="m-simpleFooter" id="pro-view-3">
    <div data-pro="text" class="m-simpleFooter-text">
        <div id="pro-view-4">共参与1件商品，总计：<em class="txt-red" id="cart_amount">${dbTimes.singleAmount*num}宝币</em></div>
    </div>
    <div data-pro="ext" class="m-simpleFooter-ext">
        <button type="submit" class="w-button w-button-main" id="pro-view-2">提交</button>
    </div>
</div>
<div class="m-cart" id="pro-view-5">
    <div class="item" id="pro-view-6" >
        <input type="hidden" name="singleAmount"  value="${dbTimes.singleAmount}"/>
        <input type="hidden" name="productId"  value="${dbProduct.id}"/>
        <input type="hidden" name="timesNo"  value="${dbTimes.timesNo}"/>
        <input type="hidden" name="purchaseQuantity"  value="${dbTimes.purchaseQuantity}"/>
        <div class="pic">
            <a href="/db/product-${dbProduct.id}-${dbTimes.timeNo}">
                <img src="${dbProduct.thumbnail}" alt="${dbProduct.name}">
            </a>
        </div>
        <div class="text">
            <h1 class="title">
              <a href="/db/product-${dbProduct.id}-${dbTimes.timeNo}">${dbProduct.name}</a>
         </h1>
            <div>总需 ${dbTimes.quantity} 人次，剩余 <em class="remain">${dbTimes.quantity-dbTimes.currentQuantity}</em>人次</div>
            <div>参与人次
                <div class="w-number" id="pro-view-7">
                    <input class="w-number-input" data-pro="input" name="num" value="${num}" pattern="[0-9]*">
                    <a class="w-number-btn w-number-btn-plus" data-action="addNum" data-pro="plus"   href="javascript:void(0);">+</a>
                    <a class="w-number-btn w-number-btn-minus" data-action="moveNum" data-pro="minus"  href="javascript:void(0);">-</a>
                </div>
            </div>
            <a href="javascript:void(0);" data-pro="del" class="del">
                <i class="ico ico-del"></i>
            </a>
        </div>
    </div>
</div>
</form>
<script type="text/javascript">
$(function(){
    var singleAmount=parseFloat($("input[name='singleAmount']").val());
    var purchaseQuantity=parseFloat($("input[name='purchaseQuantity']").val())
    var stepNum=parseInt('${dbTimes.stepNum}');
    $("a[data-action='moveNum']").click(function(){
        var currentNum=$("input[name='num']").val();
        var num=parseInt(currentNum);
        if(num==stepNum){
            alert("不能再减少");
            return;
        }
        $("input[name='num']").val(num-stepNum);
        $("#cart_amount").html((num-stepNum)*singleAmount+"宝币");
    });
    $("a[data-action='addNum']").click(function(){
        var currentNum=$("input[name='num']").val();
        var num=parseInt(currentNum);
        if(num+stepNum>purchaseQuantity){
            alert("单用户最大限制为:"+purchaseQuantity+"份");
            return;
        }
        $("input[name='num']").val(num+stepNum);
        $("#cart_amount").html((num+stepNum)*singleAmount+"宝币");
    });

    $("input[name='num']").change(function(){
        var current=$("input[name='num']").val();
        if(current%stepNum!=0){
            alert("必须是:"+stepNum+"的整数倍");
           $("input[name='num']").val(stepNum);
            current=stepNum;
        }
         if(current>purchaseQuantity){
             alert("单用户最大限制为:"+purchaseQuantity+"份");
             current=purchaseQuantity;
             $("input[name='num']").val(purchaseQuantity);
         }
        $("#cart_amount").html(current*singleAmount+"宝币");
    });
});
</script>
<div class="cnzz" style="display: none;">
    <script src="http://s4.cnzz.com/z_stat.php?id=1256836410&web_id=1256836410" language="JavaScript"></script>
</div>
</body>
</html>